import {View, Button, Text, Image, ScrollView} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React from 'react';
import {connect} from 'react-redux';
import * as T from '../../types';
import './index.less';
import actions from '../../actions';
import {store2Props} from '../../selectors';
import notdata from '@/assets/image/ipland/notdata.png';

//@ts-ignore
actions().actions.loadReducer();
//@ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class toBeCollected extends React.Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {
      list: [],
      refresherTriggered: false,
    };
  }

  componentDidMount() {}

  componentWillUnmount() {
    this.props.actions.clean();
  }

  componentWillMount(): void {
    this.props.actions.init();
  }

  componentDidShow() {}
  _onRefresherRefresh = () => {
    // let {refresherTriggered} = this.state;
    // if (refresherTriggered) return;
    // this.setState({
    //   refresherTriggered: true,
    // });
    // // this.props.actions.action.commonChange('main.myRewardList', []);
    // this.props.actions.action.commonChange('main.pageNum', 0);
    // this.props.actions.action.getMyReward();
    // setTimeout(() => {
    //   this.setState({
    //     refresherTriggered: false,
    //   });
    // }, 2000);
    console.log('刷新====');
  };

  handleLoadMore = async () => {
    // let {
    //   main: {pageNum, totalPages},
    // } = this.props;
    // if (pageNum + 1 == totalPages) return;
    // let num = pageNum + 1;
    // await this.props.actions.action.commonChange('main.pageNum', num);
    // await this.props.actions.action.getMyReward();
    console.log('加载');
  };
  render() {
    let {list, refresherTriggered} = this.state;
    return (
      <View className="packageIGameCurrencyDetails-AllDetails">
        {!list ? (
          <ScrollView
            className="ScrollView"
            scrollY
            refresherEnabled
            refresherTriggered={refresherTriggered}
            onScrollToLower={this.handleLoadMore}
            onRefresherPulling={this._onRefresherRefresh}
          >
            <View className="item">
              <View className="item-left">
                <View className="item-info">
                  <Text className="item-info-name">游戏币充值100元</Text>
                  <Text className="item-info-price1">充值时间：2023-09-09 14:34:09</Text>
                </View>
              </View>
              <View className="item-controll">
                <Text className="item-controll-add">+100</Text>
              </View>
            </View>
            <View className="item">
              <View className="item-left">
                <View className="item-info">
                  <Text className="item-info-name">游戏币充值100元</Text>
                  <Text className="item-info-price1">充值时间：2023-09-09 14:34:09</Text>
                </View>
              </View>
              <View className="item-controll">
                <Text className="item-controll-reduce">-1</Text>
              </View>
            </View>
          </ScrollView>
        ) : (
          <View className="notdataBox">
            <View className="notdataCon">
              <Image className="notdatabg" src={notdata} mode="widthFix" />
              <Text className="notdataText">啊哦~空空如也~</Text>
            </View>
          </View>
        )}
      </View>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
